package com.taikang.hmp.hbusiness.diabetes.measure.information.action.intface;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.taikang.hmp.frame.common.TKException;
import com.taikang.hmp.frame.common.datastructre.Dto;
import com.taikang.hmp.frame.common.datastructre.support.BaseDto;
import com.taikang.hmp.frame.common.datastructre.support.ResponseDto;
import com.taikang.hmp.frame.common.web.action.BaseAction;
import com.taikang.hmp.hbusiness.diabetes.measure.information.service.IInformationService;

/** 
 * 公告通知
 * author:qrp
 * time:2015年12月15日 上午10:17:22
 */
public class InformationAction extends BaseAction{
	private static final long serialVersionUID = 1L;
	private static Logger logger = LoggerFactory.getLogger(InformationAction.class);
	
	private IInformationService informationService;
	

	public IInformationService getInformationService() {
		return informationService;
	}

	public void setInformationService(IInformationService informationService) {
		this.informationService = informationService;
	}

	public String executeAction() {
		if ("getHotQuestionList".equals(requestDto.getMethod())) { 
			logger.info("--【获取热点问题列表】: method getHotQuestionList --");
			return getHotQuestionList();
		}else if ("getHotQuestionDetail".equals(requestDto.getMethod())) { 
			logger.info("--【获取热点问题详情】: method getHotQuestionDetail --");
			return getHotQuestionDetail();
		} else {
			logger.info("executeAction 里没有配置"+ requestDto.getMethod() +"方法!");
			throw new TKException("no support method:" + requestDto.getMethod());
		}
	}
	
	/**
	 * 获取热点问题列表
	 * @return
	 */
	public String getHotQuestionList(){
		
		ResponseDto responseDto = new ResponseDto();
		//获取参数
	    Dto paramDto = requestDto.getRequestlist().get(0);
	    paramDto = super.appendRequestBase(paramDto, requestDto);
	    
	    List<Dto> result = informationService.getHotQuestionList(paramDto);	
	    Dto resultDto = new BaseDto();
		resultDto.put("resultlist", result);
		String muid = informationService.gethealtherInfo(requestDto.getUid());
		resultDto.put("muid", muid);
		responseDto.pushResultDto(resultDto);
		//
		super.setDataMap(responseDto);
		return SUCCESS;
	}
	/**
	 * 获取热点问题详情
	 * @return
	 */
	public String getHotQuestionDetail(){
		ResponseDto responseDto = new ResponseDto();	
		//获取参数
		Dto paramDto = requestDto.getRequestlist().get(0);
		paramDto = super.appendRequestBase(paramDto, requestDto);
		
		informationService.getHotQuestionDetail(paramDto);

		super.setDataMap(responseDto);
		return SUCCESS;
	}
	

}
